/*
Copyright © 2024 NAME HERE <EMAIL ADDRESS>
*/
package cmd

import (
	"fmt"
	"github.com/fatih/color"
	"github.com/spf13/cobra"
	"os"
)

var (
	Version = "Beta v1.0.0"
	banner  = ` dP""b8  dP"Yb  8888b.  888888     888888  dP"Yb   dP"Yb  88     
dP   '" dP   Yb  8I  Yb 88__         88   dP   Yb dP   Yb 88     
Yb      Yb   dP  8I  dY 88""         88   Yb   dP Yb   dP 88  .o
YboodP  YbodP  8888Y"  888888       88    YbodP   YbodP  88ood8 ` + color.New(color.BgHiWhite, color.FgHiMagenta, color.Bold).Sprintf(" - "+Version+" - ")
)

var rootCmd = &cobra.Command{
	Use:   "codetool",
	Short: "编码工具",
	Long:  `编码中常用的工具集.`,
	PersistentPreRun: func(cmd *cobra.Command, args []string) {
		fmt.Println()
		color.HiRed(banner)
		fmt.Println()
	},
	Run: func(cmd *cobra.Command, args []string) {
		fmt.Println()
		cmd.SetArgs([]string{"-h"})
		_ = cmd.Execute()
	},
}

func Execute() {
	rootCmd.CompletionOptions.DisableDefaultCmd = true
	rootCmd.SetHelpCommand(&cobra.Command{
		Hidden: true,
	})
	err := rootCmd.Execute()
	if err != nil {
		os.Exit(1)
	}
}
